package cn.wolfcode.wolf2w.destination.factory;

import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.destination.RemoteDestinationServer;
import cn.wolfcode.wolf2w.destination.entity.TaDestination;
import org.apache.commons.compress.utils.Lists;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteDestinationFallbackFactory implements FallbackFactory<RemoteDestinationServer> {
    @Override
    public RemoteDestinationServer create(Throwable cause) {
        return new RemoteDestinationServer() {
            @Override
            public R<TaDestination> getById(Long id) {
                TaDestination destination = new TaDestination();
                destination.setId(-1l);
                destination.setName("目的地错误");
                return R.fail(destination);
            }

            @Override
            public R<List<TaDestination>> list(String source) {
                return R.fail(Lists.newArrayList(), "查询目的地列表信息失败:" + cause.getMessage());
            }


        };
    }
}
